#ifndef COPIERHANDLER_H
#define COPIERHANDLER_H

#include <QObject>
#include "foldercopierthread.h"
#include "discdata.h"

class CopierHandler : public QObject
{
    Q_OBJECT
public:
    explicit CopierHandler(QString letter, const char *source,  QString to,QString finalPath, QObject *parent= 0);
    ~CopierHandler();
    void startCopyDisc(DiscData discData);
    void startCopyDisc();
    void stopCopyDisc();
    void setDiscData(DiscData discData);
    void setDestinatinPath(QString value);

    QString getDestinatinPath();

signals:
    void finished(QString id,QString path,QString discId,bool parentalControl);
    void canceled(QString id,QString path,QString discId,bool parentalControl);
    void readyToCopy();
    void updateProgress(int value);
    void sendProgress(int value);

public slots:
    void copyFinished(QString id, QString path, QString discId, bool parentalControl);
    void copyCanceled(QString id, QString path, QString discId, bool parentalControl);
    void copyDisc();
    void setDiscDataList(QList<DiscData> discData);
    void checkProgress();
    void changeLetter(QString);
    void changeTempFolder(QString path);
    void changeFinalFolder(QString path);

    void processFinished(int exitCode,QProcess::ExitStatus exitStatus);
    void readyReadStandardOutput();
    void startRobocopy(QString id,QString path,QString discId,bool parentalControl);

private:
    void calculateTotalSize(const QString &path);
    void calculateAlreadyCopied(const QString &path);
    void removeFolder(const QString &path);

    FolderCopierThread *_copier;
    QTimer  timer;
    QList<DiscData> _discDataList;
    DiscData _discData;
    QString _driveLetter;
    QString _destinationPath;
    QString _tempPath;
    QString _source;
    QProcess    *_proc;
    float _totalSize;
    float _copiedSize;
    int _progress;
    //
    QString _id;
    QString _discId;
    bool _parentalControl;

    
};

#endif // COPIERHANDLER_H
